//
//  LYSelectedClassesViewController.m
//  artist
//
//  Created by laotang on 16/4/18.
//  Copyright © 2016年 viviyoo. All rights reserved.
//

#import "LYSelectedClassesViewController.h"
#import "LYSubjectListDBTool.h"
@interface LYSelectedClassesViewController()
@property (weak, nonatomic) LYChooseListView *listView;

@end

@implementation LYSelectedClassesViewController

- (void)viewDidLoad{
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor whiteColor];
    self.title = @"课程信息";
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStylePlain target:nil action:nil];
    self.navigationItem.rightBarButtonItem.title = @"发布";
    [self listView];
}


- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];

}

- (LYChooseListView *)listView{
    if (_listView == nil) {
        _listView  = [LYChooseListView showOnView:self.view WithMode:listModeNormal];
        
        WS(weakSelf)
        [_listView setBlock:^(NSString *subject){
            
            NSInteger subjectid= [LYSubjectListDBTool getIDWithSubTitle:subject];
            [weakSelf updateInterestDataWithSubjectStr:subjectid];
        }];
    }
    return _listView;
    
}


- (void)updateInterestDataWithSubjectStr:(NSInteger )subjects{
   
    self.uploadModel.subject_id = [@(subjects) stringValue];
    self.uploadModel.token = [AppDelegate shareInstance].token;
    [SVProgressHUD showWithStatus:@"发布中"];
    [LYRequestTool addSubjecWithParmeterModel:self.uploadModel success:^(NSString * string) {
        [SVProgressHUD showSuccessWithStatus:@"发布成功"];
        UINavigationController *nav =  [LYRootViewController selectedViewController];
        [nav popToRootViewControllerAnimated:YES];
        
    } failure:^(NSString *code, NSString *message) {
        [MBProgressHUD showError:message];
    }];
    
}

@end
